package com.itheima.controller;

import com.itheima.domain.User;
import com.itheima.service.UserService;

import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserController1 {
    public static void main(String[] args) {
//   创建对象
    ApplicationContext ac=new ClassPathXmlApplicationContext("spring.xml");

        UserService userService =(UserService) ac.getBean("userService");
        userService.findAll();
        //2、从容器获取Bean对象
//        UserService userService = (UserService) ac.getBean("userService");
//        userService.findAll();
//        手动创建对象
//        UserService us=new UserServiceImpl();
//        User u=new User();
//        u.eat();
     //使用spring调用
        User u1 = (User)ac.getBean("u");
        u1.eat();
    }
}
